
<%@page import="com.cloudbroker.bcs.common.configure.model.TenantInfo"%>
<%@page import="com.cloudbroker.bcs.platform.ltb.configure.service.TenantManager"%>
<%@page import="com.cloudbroker.bcs.platform.ltb.configure.define.ConfigureCatalog"%>
<%@page import="com.cloudbroker.bcs.platform.ltb.configure.define.XMLConfigParser"%>
<%@page import="java.util.Collection"%>
<%@ page session="false" language="java"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.HashMap"%>
<!DOCTYPE html>
<html>
<head>
<link href="/css/global.css" rel="stylesheet">
<script src="/js/jquery.js"></script>
<script type="text/javascript">
	function deleteConfig(tenantId){	
		var data = {
			"tenantId":tenantId
		};
		
		$.ajax({
			type : "post",
			data : data,
			dataType : "json",
			url : "delete",
			complete : function() {
				location.reload();
			}
		});
	}
	
	function addConfig(){
		
		var tenantId = $("#tenantId").val();
		if(tenantId == ""){
			alert("配资公司编号不能为空");
			return false;
		}
		
		var url = window.location.href;
			url = url.replace("manage","");
			url = url.replace("#","");
			url+= tenantId;
			url+= "/index";
		
		//window.location.href=url;
		window.open(url);
	}
	
	function viewConfig(tenantId){
		
		var url = window.location.href;
			url = url.replace("manage","");
			url = url.replace("#","");
			url+= tenantId;
			url+= "/index";
		
		//window.location.href=url;
		window.open(url);
	}
</script>
<style type="text/css">
.pointCursor {
cursor: pointer;
}
</style>
</head>
<body>
	<div>
        <h3>添加配资公司</h3>
		配资公司编号：<input type="text" id="tenantId" />
		<button onclick="addConfig()">确认</button>
	</div>
    <br />
	<table id="configureList" class="tableStyle" cellpadding="0"
		cellspacing="0" width="100%" align="center">
		<thead>
			<tr>
				<th class="ID">序号</th>
				<th class="borderN">配资公司编号 </th>
				<th class="borderN">配资公司名称</th>
				<th class="borderN">操作</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>1</td>
				<td>noTenant</td>
				<td>通用配置</td>
				<td>
					<a class="pointCursor" onclick="viewConfig('noTenant')" >查看</a>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<a class="pointCursor" onclick="alert('通用配置不能随便删除的，少年^_^!!')" ><font color="#8B8B83">删除</font></a>
				</td>
			</tr>
			<%
			    List<TenantInfo> tenantInfos = TenantManager.getTenantList();
			    if(!tenantInfos.isEmpty()){
			        int size = tenantInfos.size();
					for (int i=0;i<size;i++) {
					TenantInfo tenantInfo = tenantInfos.get(i);
			%>
			<tr>
				<td><%=(i+2)%></td>
				<td><%=tenantInfo.getTenantId()%></td>
				<td>
					<%
						if( !tenantInfo.getTenantName().isEmpty() ) {
							out.println( tenantInfo.getTenantName() );
						} else {
							out.println( tenantInfo.getTenantId() );
						}
					%>
				</td>
				<td>
					<a class="pointCursor" onclick="viewConfig('<%=tenantInfo.getTenantId()%>')">查看</a>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<a class="pointCursor" onclick="deleteConfig('<%=tenantInfo.getTenantId()%>')" >删除</a>
				</td>
			</tr>
			<%
			    	}
			    }
			%>
		</tbody>
	</table>
</body>
</html>
